home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Communications Toolbox / CommToolbox 1.1 / Interfaces / CIncludes / Connections.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-21  |  7.7 KB  |  284 lines  |  [TEXT/MPS ]

  1. /************************************************************
  2.     Connections.h
  3.     C Interface to the Connection Manager
  4.  
  5.         Copyright Apple Computer, Inc. 1988-1991
  6.         All rights reserved
  7. ************************************************************/
  8.  
  9.  
  10. #ifndef    __CONNECTIONS__
  11. #define __CONNECTIONS__
  12.  
  13. #ifndef __DIALOGS__
  14. #include <Dialogs.h>
  15. #endif
  16.  
  17. #ifndef __CTBUTILITIES__
  18. #include <CTBUtilities.h>
  19. #endif
  20.  
  21.  
  22. enum {
  23.  
  24.  
  25. /*    current Connection Manager version    */
  26.  curCMVersion = 2,
  27.  
  28. /*    current Connection Manager Environment Record version     */
  29.  curConnEnvRecVers = 0,
  30.  
  31. /* CMErr */
  32.  cmGenericError = -1,
  33.  cmNoErr = 0,
  34.  cmRejected = 1,
  35.  cmFailed = 2,
  36.  cmTimeOut = 3,
  37.  cmNotOpen = 4,
  38.  cmNotClosed = 5,
  39.  cmNoRequestPending = 6,
  40.  cmNotSupported = 7,
  41.  cmNoTools = 8,
  42.  cmUserCancel = 9,
  43.  cmUnknownError = 11
  44. };
  45.  
  46. typedef    OSErr CMErr;
  47.  
  48.  
  49.  
  50. enum {
  51.      cmData             = 1 << 0,
  52.     cmCntl             = 1 << 1,
  53.     cmAttn             = 1 << 2,
  54.     cmDataNoTimeout    = 1 << 4,
  55.     cmCntlNoTimeout = 1 << 5,
  56.     cmAttnNoTimeout = 1 << 6,
  57.     cmDataClean     = 1 << 8,
  58.     cmCntlClean        = 1 << 9,
  59.     cmAttnClean        = 1 << 10,
  60. /*        Only for CMRecFlags (not CMChannel) in the rest of this enum    */
  61.     cmNoMenus         = 1 << 16,
  62.     cmQuiet            = 1 << 17,
  63.     cmConfigChanged    = 1 << 18
  64. };
  65.  
  66. /* CMRecFlags and CMChannel        */
  67. /*        Low word of CMRecFlags is same as CMChannel    */
  68. typedef long CMRecFlags;
  69.  
  70.  
  71. typedef short CMChannel;
  72.  
  73.  
  74.  
  75.  
  76. enum {
  77.     cmStatusOpening = 1 << 0,
  78.     cmStatusOpen = 1 << 1,
  79.     cmStatusClosing = 1 << 2,
  80.     cmStatusDataAvail     = 1 << 3,
  81.     cmStatusCntlAvail     = 1 << 4,
  82.     cmStatusAttnAvail     = 1 << 5,
  83.  
  84.     cmStatusDRPend         = 1 << 6,        /* data read pending    */
  85.     cmStatusDWPend         = 1 << 7,        /* data write pending    */
  86.     cmStatusCRPend         = 1 << 8,        /* cntl read pending    */
  87.     cmStatusCWPend         = 1 << 9,        /* cntl write pending    */
  88.     cmStatusARPend         = 1 << 10,        /* attn read pending    */
  89.     cmStatusAWPend         = 1 << 11,        /* attn write pending    */
  90.  
  91.     cmStatusBreakPend     = 1 << 12,
  92.     cmStatusListenPend     = 1 << 13,
  93.     cmStatusIncomingCallPresent = 1 << 14,
  94.  
  95.     cmStatusReserved0    = 1 << 15
  96. };
  97. typedef unsigned long CMStatFlags;
  98.  
  99. enum {cmDataIn,cmDataOut,cmCntlIn,cmCntlOut,cmAttnIn,cmAttnOut,cmRsrvIn,
  100.  cmRsrvOut};
  101. typedef unsigned short CMBufFields;
  102.  
  103.  
  104. typedef Ptr CMBuffers[8];
  105. typedef long CMBufferSizes[8];
  106. typedef const long *ConstCMBufferSizesParam;
  107.  
  108. enum {cmSearchSevenBit =    1 << 0};
  109. typedef unsigned short CMSearchFlags;
  110.  
  111. enum {cmFlagsEOM        =    1 << 0};
  112. typedef unsigned short CMFlags;
  113.  
  114.  
  115. struct ConnEnvironRec {
  116.     short        version;
  117.     long        baudRate;
  118.     short        dataBits;
  119.     CMChannel    channels;
  120.     Boolean        swFlowControl;
  121.     Boolean        hwFlowControl;
  122.     CMFlags        flags;
  123. };
  124.  
  125. typedef struct ConnEnvironRec ConnEnvironRec;
  126. typedef ConnEnvironRec *ConnEnvironRecPtr;
  127.  
  128. struct ConnRecord {
  129.     short        procID;
  130.     CMRecFlags    flags;
  131.     CMErr        errCode;
  132.     long        refCon;
  133.     long        userData;
  134.     ProcPtr        defProc;
  135.     Ptr            config;
  136.     Ptr            oldConfig;
  137.     long        asyncEOM;
  138.     long        reserved1;
  139.     long        reserved2;
  140.     Ptr            cmPrivate;
  141.     CMBuffers        bufferArray;
  142.     CMBufferSizes    bufSizes;
  143.     long        mluField;
  144.     CMBufferSizes    asyncCount;
  145. };
  146.  
  147. typedef struct ConnRecord ConnRecord;
  148. typedef ConnRecord *ConnPtr, **ConnHandle;
  149.  
  150.  
  151. /*    application routines type definitions */
  152. typedef pascal void  (*ConnectionSearchCallBackProcPtr) (ConnHandle hConn, Ptr matchPtr, long refNum);
  153. typedef pascal void  (*ConnectionCompletionProcPtr) (ConnHandle hConn);
  154. typedef pascal void  (*ConnectionChooseIdleProcPtr) (void);
  155.  
  156. enum {
  157.  
  158.  
  159. /* CMIOPB constants and structure */
  160.  cmIOPBQType = 10,
  161.  cmIOPBversion = 0
  162. };
  163.  
  164. struct CMIOPB {
  165.     QElemPtr    qLink;
  166.     short        qType;            /* cmIOPBQType */
  167.     ConnHandle    hConn;
  168.     Ptr            theBuffer;
  169.     long        count;
  170.     CMFlags        flags;
  171.     ConnectionCompletionProcPtr userCompletion;
  172.     long        timeout;
  173.     CMErr        errCode;
  174.     CMChannel    channel;
  175.     long        asyncEOM;
  176.     long        reserved1;
  177.     short        reserved2;
  178.     short        version;        /* cmIOPBversion */
  179.     long        refCon;            /* for application */
  180.     long        toolData1;        /* for tool */
  181.     long        toolData2;        /* for tool */
  182. };
  183.  
  184. typedef struct CMIOPB CMIOPB;
  185. typedef CMIOPB *CMIOPBPtr;
  186.  
  187.  
  188. #ifdef __cplusplus
  189. extern "C" {
  190. #endif
  191. pascal CMErr        InitCM(void);
  192. pascal Handle         CMGetVersion(ConnHandle hConn);
  193. pascal short         CMGetCMVersion(void);
  194.  
  195. pascal ConnHandle    CMNew(short procID,CMRecFlags flags,ConstCMBufferSizesParam desiredSizes,
  196.                         long refCon,long userData);
  197.  
  198. pascal void         CMDispose(ConnHandle hConn);
  199.  
  200. pascal CMErr         CMListen(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  201.                         long timeout);
  202. pascal CMErr         CMAccept(ConnHandle hConn,Boolean accept);
  203.  
  204. pascal CMErr         CMOpen(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  205.                         long timeout);
  206. pascal CMErr         CMClose(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  207.                         long timeout,Boolean now);
  208.  
  209. pascal CMErr         CMAbort(ConnHandle hConn);
  210.  
  211. pascal CMErr         CMStatus(ConnHandle hConn,CMBufferSizes *sizes,CMStatFlags *flags);
  212. pascal void         CMIdle(ConnHandle hConn);
  213.  
  214. pascal void         CMReset(ConnHandle hConn);
  215.  
  216. pascal void         CMBreak(ConnHandle hConn,long duration,Boolean async,ConnectionCompletionProcPtr completor);
  217.  
  218. pascal CMErr         CMRead(ConnHandle hConn,void *theBuffer,long *toRead,CMChannel theChannel,
  219.             Boolean async,ConnectionCompletionProcPtr completor,long timeout,CMFlags *flags);
  220. pascal CMErr         CMWrite(ConnHandle hConn,const void *theBuffer,long *toWrite,
  221.             CMChannel theChannel,Boolean async,ConnectionCompletionProcPtr completor,
  222.             long timeout,CMFlags flags);
  223.  
  224. pascal CMErr         CMIOKill(ConnHandle hConn,short which);
  225.  
  226. pascal void         CMActivate(ConnHandle hConn,Boolean activate);
  227. pascal void         CMResume(ConnHandle hConn,Boolean resume);
  228. pascal Boolean         CMMenu(ConnHandle hConn,short menuID,short item);
  229.  
  230. pascal Boolean         CMValidate(ConnHandle hConn);
  231. pascal void         CMDefault(Ptr *theConfig,short procID,Boolean allocate);
  232.  
  233. pascal Handle         CMSetupPreflight(short procID,long *magicCookie);
  234. pascal Boolean         CMSetupFilter(short procID,const void *theConfig,short count,
  235.  DialogPtr theDialog,EventRecord *theEvent,short *theItem,long *magicCookie);
  236. pascal void  CMSetupSetup(short procID,const void *theConfig,short count,
  237.  DialogPtr theDialog,long *magicCookie);
  238. pascal void  CMSetupItem(short procID,const void *theConfig,short count,
  239.  DialogPtr theDialog,short *theItem,long *magicCookie);
  240. pascal void  CMSetupXCleanup(short procID,const void *theConfig,short count,
  241.  DialogPtr theDialog,Boolean OKed,long *magicCookie);
  242. pascal void  CMSetupPostflight(short procID);
  243.  
  244. pascal Ptr             CMGetConfig(ConnHandle hConn);
  245. pascal short         CMSetConfig(ConnHandle hConn,const void *thePtr);
  246.  
  247. pascal OSErr         CMIntlToEnglish(ConnHandle hConn,const void *inputPtr,Ptr *outputPtr,
  248.  short language);
  249. pascal OSErr         CMEnglishToIntl(ConnHandle hConn,const void *inputPtr,Ptr *outputPtr,
  250.  short language);
  251.  
  252. pascal long         CMAddSearch(ConnHandle hConn,ConstStr255Param theString,CMSearchFlags flags,
  253.  ConnectionSearchCallBackProcPtr callBack);
  254. pascal void            CMRemoveSearch(ConnHandle hConn,long refnum);
  255. pascal void            CMClearSearch(ConnHandle hConn);
  256.  
  257. pascal CMErr         CMGetConnEnvirons(ConnHandle hConn,ConnEnvironRec *theEnvirons);
  258.  
  259. pascal short         CMChoose(ConnHandle *hConn,Point where,ConnectionChooseIdleProcPtr idleProc);
  260.  
  261. pascal void            CMEvent(ConnHandle hConn,const EventRecord *theEvent);
  262.  
  263. pascal void         CMGetToolName(short procID,Str255 name);
  264. pascal short         CMGetProcID(ConstStr255Param name);
  265.  
  266. pascal void            CMSetRefCon(ConnHandle hConn,long refCon);
  267. pascal long         CMGetRefCon(ConnHandle hConn);
  268.  
  269. pascal long         CMGetUserData(ConnHandle hConn);
  270. pascal void         CMSetUserData(ConnHandle hConn,long userData);
  271.  
  272. pascal void            CMGetErrorString(ConnHandle hConn,short id,Str255 errMsg);
  273.  
  274. pascal CMErr          CMNewIOPB(ConnHandle hConn,CMIOPBPtr *theIOPB);
  275. pascal CMErr        CMDisposeIOPB(ConnHandle hConn,CMIOPBPtr theIOPB);
  276.  
  277. pascal CMErr        CMPBRead(ConnHandle hConn,CMIOPBPtr theIOPB,Boolean async);
  278. pascal CMErr        CMPBWrite(ConnHandle hConn,CMIOPBPtr theIOPB,Boolean async);
  279. pascal CMErr        CMPBIOKill(ConnHandle hConn,CMIOPBPtr theIOPB);
  280. #ifdef __cplusplus
  281. }
  282. #endif
  283.  
  284. #endif